﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace DevDemo
{
    public partial class UC_GridListByDev : DevExpress.XtraEditors.XtraUserControl
    {
        public UC_GridListByDev()
        {
            InitializeComponent();
        }

        private void repositoryItemButtonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            if (e.Button.Tag.ToString() == "查看")
            {
                int selectRow = gridView1.GetSelectedRows()[0];

                string id = this.gridView1.GetRowCellValue(selectRow, "0").ToString();

                MessageBox.Show("查看" + id);
            }

            if (e.Button.Tag.ToString() == "删除")
            {
                int selectRow = gridView1.GetSelectedRows()[0];

                string id = this.gridView1.GetRowCellValue(selectRow, "0").ToString();

                MessageBox.Show("删除" + id);
            }
        }

        private void UC_GridListByDev_Load(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();

            for (int i = 0; i < 4; i++)
            {
                DataColumn dc = new DataColumn
                {
                    ColumnName = i.ToString()
                };

                dt.Columns.Add(dc);
            }

            for (int i = 0; i < 4; i++)
            {
                DataRow dr = dt.NewRow();

                for (int j = 0; j < 3; j++)
                {
                    dr[j] = "va" + i.ToString();
                }

                dt.Rows.Add(dr);
            }

            this.gridControl1.DataSource = dt;
        }
    }
}
